﻿@using Telerik.Web.Mvc
@using Telerik.Web.Mvc.UI
@{
    var sel = 0;
    var path = Request.Path;
    if (path.CompareTo("/pic/upload") == 0 || path.CompareTo("/pic/upload/") == 0)
    {
        //在图片管理的位置
        sel = 0;
    }
    else
    {
        //在景区管理的位置
        sel = -1;
    }
}
@using (Html.BeginForm("uploadsight", "pic", FormMethod.Post, new { id = "uploadFormSight", enctype = "multipart/form-data" }))
{ 
    @Html.Partial("_PicUploadSettingTip")
    @(Html.Telerik().Upload()
            .Name("sightFiles")
            .Multiple(true)
    )
    <div style="margin: 20px 0 10px 0;">
        @Html.Partial("_PicUploadSettingThumb")
    </div>
    <div style="display: none;">
        <input type="hidden" value="景点" id="picType" name="picType" />
        <input type="hidden" value="@(ViewBag.sightid != null ? ViewBag.sightid : 0)" id="sightId" name="sightId" />
        <input type="hidden" value="@(Request.Path)" 
        id="@(Infrastructure.Crosscutting.Comm.Service.ConstService.UrlParaReturnUrl)"
        name="@(Infrastructure.Crosscutting.Comm.Service.ConstService.UrlParaReturnUrl)" />
        <input type="hidden" value="@(sel)" 
        id="@(Infrastructure.Crosscutting.Comm.Service.ConstService.UrlParaSelected)" 
        name="@(Infrastructure.Crosscutting.Comm.Service.ConstService.UrlParaSelected)" />
    </div>
    <div style="margin: 20px 0 10px 0;">
        <input type="submit" value="上传" class="alt_btn" onclick="return checkedFormSight();" />
        <input type="reset" value="取消" class="t-button" />
    </div>
}
<script type="text/javascript">
    function checkedFormSight() {
        var res = false;
        var files = $("#uploadFormSight input[name='sightFiles'][type='file']");
        if (files.length <= 1) {
            alert("额，请选择要上传的文件,*_*");
        }
        else {
            for (var i = 0; i < files.length - 1; i++) {
                var temp = files[i];
                if (temp.value != "") {
                    if (!temp.value.IsPicture()) {
                        res = false;
                    } else {
                        res = true;
                    }
                }
            }
            if (!res) {
                alert("部分上传的文件不是图片格式，请勿上传其他文件");
            }
        }
        return res;
    }
</script>
